package com.lin.cloud.disk.manage.impl;

import com.lin.cloud.disk.common.entity.request.AccountRequestDTO;
import com.lin.cloud.disk.entity.request.CountTotalSizeRequest;
import com.lin.cloud.disk.entity.response.CountTotalSizeResponse;
import com.lin.cloud.disk.manage.IDashboardManageService;
import com.lin.cloud.disk.service.IDepartmentService;
import com.lin.cloud.disk.service.IFileService;
import com.lin.cloud.disk.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @program: cloud-disk
 * @description:
 * @author: Lin
 * @create: 2021-03-08 17:18
 **/
@Service
public class DashboardManageServiceImpl implements IDashboardManageService {

    @Resource
    private IFileService fileService;

    @Resource
    private IDepartmentService departmentService;

    @Resource
    private IUserService userService;

    /**
     * 统计总量
     * @param request
     * @return
     */
    @Override
    public CountTotalSizeResponse countTotalFileSize(AccountRequestDTO request){
        CountTotalSizeResponse response = new CountTotalSizeResponse();

        CountTotalSizeRequest countTotalSizeRequest = new CountTotalSizeRequest();
        countTotalSizeRequest.setCompanyId(request.getUserDTO().getCompanyId());
        countTotalSizeRequest.setUserId(request.getUserDTO().getId());

        String totalFileSize = fileService.countTotalFileSize(countTotalSizeRequest);
        Integer totalDepartmentSize = departmentService.countDepartmentSize(countTotalSizeRequest);
        Integer totalUserSize = userService.countUserSize(countTotalSizeRequest);

        response.setTotalFileSize(totalFileSize);
        response.setTotalDepartmentSize(totalDepartmentSize);
        response.setTotalUserSize(totalUserSize);

        return response;

    }
}
